﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DTO;
using BUS;
namespace Nhom17_UploadFile
{
    public partial class DangNhap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        DTO_Account ac = new DTO_Account();
        BUS_ACCOUNT bus_ac = new BUS_ACCOUNT();
        protected void btndangnhap_Click(object sender, EventArgs e)
        {
            ac.Email = txtEmail.Text;
            ac.Password = txtPassword.Text;
            DataTable tb = new DataTable();
            tb = bus_ac.DangNhap(ac);
            if (tb.Rows.Count > 0)
            {


                foreach (DataRow row in tb.Rows)
                {
                    Session["ID"] = int.Parse(row[3].ToString());
                    Session["Admin"] = int.Parse(row[2].ToString());
                    Session["LastName"] = row[5].ToString();

                    if (int.Parse(row[2].ToString()) == 1)
                    {
                        Response.Redirect("admin\\Admin.aspx");
                    }
                    else
                    {
                        Response.Redirect("user\\user.aspx");
                    }
                }

            }
            else
            {
                Response.Redirect("TrangChu.aspx");
            }
        }
    }
}